<?php

if (!isset($_COOKIE['username'])) {
 echo("Log in first!");
 exit;
}

//If submit button clicked
if ($_GET['detailed']) {

 //Strips " and ' marks
 $bannedMarks = array("\"", "'");

 $_GET['language'] = str_replace($bannedMarks, "", $_GET['language']);
 $_GET['bookSerie'] = str_replace($bannedMarks, "", $_GET['bookSerie']);
 $_GET['bookNumber'] = str_replace($bannedMarks, "", $_GET['bookNumber']);
 $_GET['chapter'] = str_replace($bannedMarks, "", $_GET['chapter']);

 $dictionary = "{$_GET['language']}_{$_GET['bookSerie']}_{$_GET['bookNumber']}_{$_GET['chapter']}";
}

elseif ($_GET['freeNamed']) {

 //Strips " and ' marks
 $bannedMarks = array("\"", "'");

 $_GET['dictionary'] = str_replace($bannedMarks, "", $_GET['dictionary']);


 $dictionary = $_GET['dictionary'];
}

echo "
<h1>Add words</h1>
<p>Give a new word pair to add it to the dictionary <b>{$dictionary}</b>:</p>

 <table border='0'>
  <tr><td><p>Foreign:</p></td><td><input type='text' id='foreign' maxlength='30' size='20' /></td></tr>
  <tr><td><p>Local:</p></td><td><input type='text' id='local' maxlength='30' size='20' /></td></tr>
 </table><br />
 <input type='hidden' id='dictionary' value='{$dictionary}' />
 <input onClick='addWordsPost()' type='button' value='->'>
</form>";

?>
